Skip to content

Fix sort_page_element. ensures that sorting is stable and not random.#3978

Merged
badGarnet merged 7 commits intoUnstructured-IO:mainfrom
pprados:pprados/fix-sort-page-elements
Apr 7, 2025
Merged

Fix sort_page_element. ensures that sorting is stable and not random.#3978
badGarnet merged 7 commits intoUnstructured-IO:mainfrom
pprados:pprados/fix-sort-page-elements

Conversation

@pprados
Copy link
Copy Markdown
Contributor

@pprados pprados commented Apr 3, 2025

The sort_page_element() use the element id to sort the elements.
Two executions of the same code, on the same file, produce different results. The order of the elements is random.
This makes it impossible to write stable unit tests, for example, or to obtain reproducible results.

@pprados pprados force-pushed the pprados/fix-sort-page-elements branch from 73f713a to 0e4da68 Compare April 3, 2025 09:15
@pprados pprados marked this pull request as ready for review April 3, 2025 09:36
@badGarnet
Copy link
Copy Markdown
Collaborator

Hi @pprados could you please write up a unit test that:

  • reproduces the issue you discovered without the fix
  • test passes with the fix
    Thanks!

@pprados pprados force-pushed the pprados/fix-sort-page-elements branch from 4534f07 to ca263ec Compare April 7, 2025 14:39
pprados added 3 commits April 7, 2025 16:39
…into pprados/fix-sort-page-elements

# Conflicts:
#	test_unstructured/partition/pdf_image/test_pdf.py
Comment thread test_unstructured/partition/pdf_image/test_pdf.py Outdated
@pprados
Copy link
Copy Markdown
Contributor Author

pprados commented Apr 7, 2025

done.
You can remove the fix in sorting.py to see the bug.

@badGarnet badGarnet added this pull request to the merge queue Apr 7, 2025
@badGarnet
Copy link
Copy Markdown
Collaborator

done. You can remove the fix in sorting.py to see the bug.

approved. Thanks for the contribution!

Merged via the queue into Unstructured-IO:main with commit d570f46 Apr 7, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants